package com.qfmy.core.pojo.entity;

import lombok.Data;

/**
 * @ClassName: ResultMessage
 * @author： zhengjt
 * @data： 2022/4/10 14:03
 * @version：1.0
 * @描述： 全局统一返回对象
 */
@Data
public class ResultMessage {

    /**
     * 操作情况 ： 成功/失败 (true/false)
     */
    private Boolean success;

    /**
     * 返回状态代码
     */
    private Integer code;

    /**
     * token 信息，用户前后端分离使用
     */
    private String token;

    /**
     * 异常提示信息（错误返回信息）
     */
    private String message;

    /**
     * 返回参数数据
     */
    private Object data;

    public ResultMessage() {
    }

    /**
     * 定义返回对象
     */
    public ResultMessage(Boolean success) {
        this.success = success;
    }

    public ResultMessage(Boolean success, Integer code) {
        this.success = success;
        this.code = code;
    }

    public ResultMessage(Boolean success, Integer code, String message) {
        this.success = success;
        this.code = code;
        this.message = message;
    }

    public ResultMessage(Boolean success, Integer code, Object data) {
        this.success = success;
        this.code = code;
        this.data = data;
    }

    public ResultMessage(Boolean success, Integer code, String message, Object data) {
        this.success = success;
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public ResultMessage(Boolean success, Integer code, String token, String message, Object data) {
        this.success = success;
        this.code = code;
        this.token = token;
        this.message = message;
        this.data = data;
    }

    /**
     * 定义一个返回成功的对象
     */
    public static ResultMessage success(Object data){
        return new ResultMessage(true,200, data);
    }
    public static ResultMessage success(){
        return new ResultMessage(true,200);
    }

}
